var mapIds = [921140000, 921140001];
var 准备地图 = 211061001;
var emName = "副本_狮子王城_秘密走廊";

function init() {}

function setup(c, a) {
    em.setProperty("state", 1);
    em.setProperty("leader", "true");
    var c = em.newInstance(emName);
    for (var b = 0; b < mapIds.length; b++) {
        var e = c.setInstanceMap(mapIds[b]);
        e.resetFully();
        e.killAllMonsters(false)
    }
    var e = em.getMapFactoryMap(mapIds[0]);
    for (var b = 0; b < 20; b++) {
        var d = em.getMonster(9300834);
        c.registerMonster(d);
        e.spawnMonsterOnGroundBelow(d, new java.awt.Point(randomNum(-2000, 1400), -140))
    }
    var d = em.getMonster(9300295);
    c.registerMonster(d);
    e.spawnMonsterOnGroundBelow(d, new java.awt.Point(1576, -140));
    return c
}

function onPlayerRegistered(b, a) {
    var c = b.getMapInstance(0);
    a.changeMap(c, c.getPortal(0));
    a.dropMessage(-1, "清空前往接待室的道路，带着伊帕娅前进吧。");
    b.startEventTimer(10 * 60 * 1000)
}

function onPlayerRevived(b, a) {
    return false
}

function onMapChanged(c, b, a) {
    if (mapIds.indexOf(a) < 0) {
        on玩家退场(c, b, false);
        return
    }
    initProp("kill", 0)
}

function onPlayerDisconnected(b, a) {
    on玩家退场(b, a, false);
    return 0
}

function onTimeOut(a) {
    a.getPlayers().forEach(function (b) {
        on玩家退场(a, b, true)
    })
}

function onMonsterKilled(b, c) {
    var d = 20;
    var a = em.getNumberProperty("kill") + 1;
    em.setProperty("kill", a);
    if (a >= d) {
        b.getPlayers().forEach(function (e) {
            e.getAPI().openNpc(2540005, "特效_完成");
            e.dropMessage(-1, "前往接待室的道路已经清空了。可以带着伊帕娅前进了。");
            e.updateInfoQuest(3178, "clear")
        })
    }
    return 1
}

function onPlayerRevived(b, a) {
    return false
}

function onPartyDisbanded(a) {}

function onPlayerKilled(b, a) {}
var setupTask;

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
}

function initProp(a, b) {
    if (em.getProperty(a) == null) {
        em.setProperty(a, b)
    }
}

function initPropArray(a, d, c, e) {
    for (var b = c; b <= e; b++) {
        if (em.getProperty(a + "_" + b) == null) {
            em.setProperty(a + "_" + b, d)
        }
    }
}

function on玩家退场(c, b, a) {
    c.disposeIfPlayerBelow(a ? 999 : 0, 准备地图);
    em.getProperties().clear();
    em.setProperty("state", 0);
    em.setProperty("leader", "true");
    c.unregisterPlayer(b)
}

function isLeader(a) {
    return a.getParty().getLeader().getId() == a.getId()
};